<template>
  <div v-loading="loading">
    <!-- 统计相关 开始 -->
    <div class="total-container">
      <!-- <el-form ref="totalFilterForm" :model="totalFilterForm" label-width="100px" size="small">
        <el-form-item label="便捷日期：">
          <el-button-group class="quick-btn-group">
            <el-button
              v-for="(v,i) in quickDateOptions"
              :key="v.val"
              :type="quickDateIndex===i?'primary':''"
              @click="quickDateSearch(v.val,i)"
            >{{v.label}}</el-button>
          </el-button-group>
        </el-form-item>
        <el-form-item
          label="选择时间："
          prop="date"
          :rules="[{ required: true, message: '时间区间不能为空' }]"
        >
          <el-date-picker
            v-model="totalFilterForm.date"
            type="datetimerange"
            range-separator="~"
            value-format="yyyy-MM-dd HH:mm:ss"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="dateChange"
          ></el-date-picker>
        </el-form-item>
      </el-form>-->

      <!-- 活动用户数据 -->
      <!-- <AppMainSubTitle title="活动用户数据" /> -->
      <!-- <div>
        <el-row :gutter="10">
          <el-col :xs="8" :sm="6" :md="6">
            <el-card></el-card>
          </el-col>
          <el-col :xs="8" :sm="6" :md="6">
            <el-card></el-card>
          </el-col>
          <el-col :xs="8" :sm="6" :md="6">
            <el-card></el-card>
          </el-col>
          <el-col :xs="8" :sm="6" :md="6">
            <el-card></el-card>
          </el-col>
        </el-row>
      </div>-->

      <!-- 活动营销数据 -->
      <div>
        <AppMainSubTitle title="活动营销数据" />
        <AppTableStatisticsCard :statistics-card-data="statisticsCardData" />
      </div>

      <!-- 券派发汇总 -->
    </div>
    <!-- 统计相关 结束-->
  </div>
</template>

<script>
import { getActivityStatistics } from '@/api/marketing'
export default {
  props: {
    activityDetail: {
      require: true
    }
  },
  data() {
    return {
      // 配置
      // 状态
      loading: false,
      // 数据
      totalFilterForm: {
        date: ''
      },
      statisticsCardData: [{
        title: '累计发券数 / 张',
        value: 0,
        describeList: [],
        detailList: []
      },
      {
        title: '累计送余额 / 元',
        value: 0,
        describeList: [],
        detailList: []
      }, {
        title: '累计送积分 / 个',
        value: 0,
        describeList: [],
        detailList: []
      }],
      total: {}
    }
  },
  computed: {},
  watch: {},
  beforeCreate() {
  },
  created() {
  },
  beforeMount() {
  },
  mounted() {
    this.fetchData()
  },
  beforeUpdate() {
  },
  update() {
  },
  activated() {
  },
  deactivated() {
  },
  beforeDestroy() {
  },
  destroyed() {
  },
  methods: {
    /**
     * 数据组
     */
    // 获取统计
    fetchData() {
      this.loading = true
      const params = { activityId: this.activityDetail.id }
      getActivityStatistics(params)
        .then((res) => {
          if (res.data) {
            this.statisticsCardData[0].value = res.data.coupon || 0
            this.statisticsCardData[1].value = res.data.balance && res.data.balance / 100 || 0
            this.statisticsCardData[2].value = res.data.points || 0
          }
        })
        .finally(() => {
          this.loading = false
        })
    }
    /**
     * 按钮组
     */
    /**
     * 状态组
     */
    /**
     * 方法组
     */
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
/* 统计 */
.total-container {
  .common-container{
    margin-bottom: 10px;
  }
}
</style>
